package com.study.modules.designPatterns.No2PolicyMode;

import java.math.BigDecimal;

/**
 * 策略模式
 * 定义上下文类
 */
public class Calculator {
    // 策略
    private Strategy strategy;

    /**
     * 设置策略
     *
     * @param strategy 策略
     */
    public void setStrategy(Strategy strategy) {
        this.strategy = strategy;
    }

    /**
     * 计算
     *
     * @param num1 num1
     * @param num2 num2
     * @return BigDecimal
     */
    public BigDecimal calculator(BigDecimal num1, BigDecimal num2) {
        return strategy.execute(num1, num2);
    }
}
